import Vue from 'vue'
import Vuex from 'vuex'
import router from '../router'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		lightArea: 0,
		light: null,
		wind: null,
		windEq: 0,
		maxYears: null,
		types: null,
		dList: [],
		// 用户信息
		userInfo: localStorage.getItem('userInfo') ? JSON.parse(localStorage.getItem('userInfo')) : null,
		defaultList: [
			{ //阳逻港
				radiationIntensity: 1239,
				efficiency: 3.45,
				burnIn: 49.42
			},
			{ // 青岛港
				radiationIntensity: 1451,
				efficiency: 5.05,
				burnIn: 149.53
			},
			{ // 天津港
				radiationIntensity: 1339,
				efficiency: 4.66,
				burnIn: 109.2
			},
			{ // 宁波舟山港
				radiationIntensity: 1272,
				photoelectricConversionEfficiency: 17.28,
				shadingCoefficient: 0.87,
				unitPrice: 600,
				annualMaintenanceCosts: 45,
				serviceLife: 1,
				cycleCarbonEmission: 5.29,
				utilizationCoefficient: 0.8,
				agingCoefficient: 0.98,
				electricityPrice: 0.725,
				designLife: 25,
				photovoltaicPanelArea: null,
				carbonEmissionFactor: 0.7663,

			},
		],
		defaultList2: [
			{ //阳逻港
				radiationIntensity: 1239,
				efficiency: 3.45,
				burnIn: 49.42
			},
			{ // 青岛港
				radiationIntensity: 1451,
				efficiency: 5.05,
				burnIn: 149.53
			},
			{ // 天津港
				radiationIntensity: 1339,
				efficiency: 4.66,
				burnIn: 109.2
			},
			{ // 宁波舟山港
				windSpeed: 7.26,
				windTurbineNumber: null,
				unitPrice: 400,
				operatingLife: 25,
				useFixedNumberOfYear: 1,
				correctionFactor: 0.8139,
				industrialElectricityPrice: 0.725,
				carbonEmission: 0.7663,
				ratedPower: 2000,
				windPowerDensity: 274.4,
			},
		],
	},
	getters: {
	},
	mutations: {
		condition(state, data) {
			state.types = data
		},
		changeYears(state, data) {
			state.maxYears = data
		},
		outPut(state, data) {
			state.dList = data
		},
		saveLight(state, data) {
			state.light = data
		},
		saveWind(state, data) {
			state.wind = data
		},
		// 修改光伏板面积
		updateLightArea(state, data) {
			state.lightArea = data
		},
		// 修改风机台数
		updateWindEq(state, data) {
			state.windEq = data
		},
		//登录
		Login(state, data) {
			// localStorage.setItem("userInfo", JSON.stringify(userinfo));
			// state.userInfo = userinfo;
			localStorage.setItem("token", data)
		},
		// 退出登录
		loginOut(state) {
			// state.userInfo = ""
			// localStorage.removeItem("userInfo")
			// state.token = null
			// state.lightArea = 0
			// state.light = null
			// state.wind = null
			// state.windEq = 0
			// state.maxYears = null
			// state.types = null
			localStorage.removeItem("token")
			router.replace("/login")
			location.reload()
		}
	},
	actions: {
	},
	modules: {
	}
})
